Skip to main content

Functions of Functions and the Exponential Function

Exponential Growth and Decline

Exponential growth is typically expressed as

y(t)=Aekty(t)=Ae^{kt}

Fig. 12

Figure: Exponential growth curve

Details

Definition

Exponential growth is the rate of population increase across time when a population is devoid of limiting factors (i.e. competition, resources, etc.) and experiences a constant growth rate.

Exponential growth is typically expressed as:

y(t)=Aekty(t)=Ae^{kt}

where

  • A (sometimes denoted P) = initial population size
  • k = growth rate
  • t =number of time intervals
Note

Note that exponential growth occurs when k>0k>0 and exponential decline occurs when k<0k<0.

The Exponential Function

An exponential function is a function with the form: f(x)=bxf(x)=b^x

Details

For the exponential function f(x)=bxf(x)=b^x, xx is a positive integer and bb is a fixed positive real number. The equation can be rewritten as:

f(x)=bx=bbbbf(x)=b^x=b\cdot b \cdot b \cdot \dots \cdot b

When the exponential function is written as f(x)=exf(x)=e^x then, it has a growth rate at time xx equivalent to the value of exe^x for the function at xx.

Properties of the Exponential Function

Recall that the methods of the basic arithmetic implies that:

ea+b=eaebe^{a+b} = e^a e^b

for any real numbers aa and bb.

Functions of Functions

Details

Consider two functions, ff and gg, each defined for some set of real numbers. Where xx can be solved in function ff using Y=f(x)Y = f(x) when g(Y)g(Y) exists for all such resulting yy. If y=f(x)y = f(x) and g(y)g(y) exist then we can compute g(f(x))g(f(x)) for any xx.

If

f(x)=x2 and g(y)=eyf(x) = {x}^2 \text{ and } g(y)= {e}^y

then

g(f(x))=ef(x)=ex2g(f(x))= {e}^{f(x)} = {e}^{x^2}

If we call the resulting function hh, then h(x)=g(f(x))h(x) = g(f(x)). Another common notation for this is

h=gfh = g\circ f

Examples

Example

If g(x)=3+2xg(x)= {3}+ {2}x and f(x)=5x2f(x) = {5}{x}^2, then

g(f(x))=3+2f(x)=3+10x2,g(f(x)) = {3} +{2} f(x) = {3} +{10x}^2,

and

f(g(x))=5(g(x))2=5(3+2x)2=45+60x+20x2f(g(x)) = {5}{(g(x))}^2 = {5}{({3}+{2x})}^2 = {45}+{60x}+{20x}^2

Storing and Using R Code

As R code gets more complex (more lines) it is usually stored in files. Functions are typically stored in separate files.

Examples

Example

Save the following file (test.r):

x=4
y=8
cat("x+y is", x+y, "\n")

To read the file use:

source("test.r")

and the outcome of the equation is displayed in R.

Storing and Calling Functions In R

To save a function in a separate file use a command of the form function.r.

Examples

Example
f<-function(x) { return (exp(sum(x))) }

can be stored in a file function.r and subsequently read using the source command.